package com.example.flutterapptest2

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import pub.devrel.easypermissions.EasyPermissions


class MainActivity : FlutterActivity() {
    private val CHANNEL = "samples.flutter.io/battery"
    private lateinit var methodChannelTest : MethodChannelTest

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
        setMethod(flutterEngine);
    }
    private fun setMethod(flutterEngine: FlutterEngine) {
        methodChannelTest = MethodChannelTest(context, flutterEngine.dartExecutor, CHANNEL)
        methodChannelTest.getBattery()
    }

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)

        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, methodChannelTest);
    }
}
